import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by baiguantao on 2017/10/20.
 */
public class T {
    public static boolean testA(char a) {
        System.out.print(a);
        return true;

    }

    /**
     * for循环的一些疑问
     *
     * @param args
     */
    public static void main2(String[] args) {
        int i = 0;
        for (testA('a'); testA('b') && (i < 2); testA('c')) {
            i++;
            testA('d');
        }
        char a = 'a';
        System.out.println("     a的asii码:" + (byte) a);
    }

    public static void main(String[] args) throws ParseException {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 开始时间
        Date date = sdf.parse("2018-1-1 1:21:29");
        // 转换换成时间戳
        long ts = date.getTime() / 1000;


        Date date12 = new Date(date.getTime());
        //打印开始日期
        String rsd = sdf.format(date12);
        System.out.println("打印开始日期" + rsd);

	/*	String res = String.valueOf(ts);
		System.out.println(res);*/

        // 现在的时间
        Date date1 = sdf.parse("2018-1-2 1:23:29");
        long time = date1.getTime() / 1000;


        Date date13 = new Date(date1.getTime());
        //打印结束日期
        String rn = sdf.format(date13);
        System.out.println("打印结束日期" + rn);


		/*String r= String.valueOf(ts);
		System.out.println(r);*/
	/*	long time = System.currentTimeMillis();
		String t = String.valueOf(time / 1000);
		System.out.println(t);*/

        long abc = time - ts;

//        long day=abc/86400;
//        long hour=abc/ 3600 % 24;
//        long secound=abc/ 144 % 60;
//        long mill=abc/ 86400 % 60;
        long secound = 0;
        long min = 0;
        long hour = 0;
        long day = abc / 86400;
        //秒
        if (abc < 60) {
            secound = abc;
        } else {
            //分
            min = abc / 60;
            secound = abc % 60;
            if (abc >= 3600) {
                hour = abc / 3600;
                if (abc > 86400) {
                    day = abc / 86400;
                }

            }
        }

        System.out.println(day + "天" + hour + "时" + min + "分" + secound + "秒");

        // Demo2.getDatePoor(ts, time);

    }

}
